import api from '../../api';
import { message } from 'antd';

export default {
  namespace: 'bondOfflineM', //债券网下
  state: {},
  effects: {
    //指令下达新增
    *orderSave({ payload, callback }, { call, put }) {
      const response = yield call(api.addOrder, payload);
      callback(response);
    },
    //簿记新增 修改
    *tradeBookSave({ payload, callback }, { call, put }) {
      const response = yield call(api.addTradeBook, payload);
      callback(response);
    },
    //中签
    *luckyNumber({ payload, callback }, { call, put }) {
      const response = yield call(api.bondOffline.luckyNumber, payload);
      callback(response);
    },

    //查询债券发行信息
    *queryBondInfo({ payload, callback }, { call, put }) {
      const response = yield call(api.bondOffline.queryBondInfo, payload);
      if (response && response.code == 0) {
        callback(response.data.dataSource);
      } else {
        message.error(response ? response.msg : '查询债券发行信息失败!');
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return { ...state, ...payload };
    },
  },
};
